package com.tr.gaoji;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author TRasdzz
 * @version 1.0
 * @since create in 2021/3/12 12:11
 */
//测试线程池
public class TestPool {
    public static void main(String[] args) {
        //创建服务 创建线程池
        //newFixedThreadPool 参数为：线程池大小
        ExecutorService executorService = Executors.newFixedThreadPool(10);
    
        //执行
        executorService.execute(new MyThread());
        executorService.execute(new MyThread());
        executorService.execute(new MyThread());
        executorService.execute(new MyThread());
        
        //关闭连接
        executorService.shutdown();
        
    }
}

class MyThread implements Runnable{
    
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}
